//
//  QRSingleton.m
//  QRMaster
//
//  Created by myApple on 15/11/11.
//  Copyright (c) 2015年 myApple. All rights reserved.
//

#import "QRSingleton.h"

@implementation QRSingleton

+(QRSingleton *)sharedQRSingleton
{
    static QRSingleton * singleton = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        if (singleton == nil) {
            singleton = [[super allocWithZone:NULL]init];
        }
    });
    return singleton;
}

-(void)setCurrentAreaCodeString:(NSString *)currentAreaCodeString
{
    _currentAreaCodeString = currentAreaCodeString;
    [[NSUserDefaults standardUserDefaults] setObject:currentAreaCodeString forKey:@"currentAreaCode"];
    [[NSUserDefaults standardUserDefaults]synchronize];
    for (int i = 0 ; i < AreaCodeArray.count; i ++) {
        if ([currentAreaCodeString isEqualToString:AreaCodeArray[i]]) {
            _currentAreaString = AreaArray[i];
        }
    }
}

-(NSString *)roleName
{
    
    switch (_roleIndex) {
        case 1:
            _roleName = NSLocalizedString(@"manager", @"超级管理员");
            break;
        case 2:
            _roleName = NSLocalizedString(@"groupManagement", @"子管理员");
            break;
        case 3:
            _roleName = NSLocalizedString(@"general", @"普通职员");
            break;
        case 4:
            _roleName = NSLocalizedString(@"normalGuest", @"普通客户");
            break;
        default:
            _roleName = NSLocalizedString(@"general", @"组管理员");
            break;
    }
    return _roleName;
}

-(void)singleRelease
{
    self.communityId = nil;
    self.roleIndex = 0;
    self.roleName = nil;
    self.groupEndTime = nil;
    self.groupBeginTime = nil;
    self.managementIndex = 0;
    self.communityName = nil;
    self.allName = nil;
    self.buildingName = nil;
    self.floorName = nil;
    self.roomName = nil;
    self.roomId = nil;
    self.groupPush = 0;
    self.guestPushIndex = 2;
    self.timeStatus = 0;
    self.currentAreaCodeString = nil;
    self.currentAreaString = nil;
}

@end
